<template>
  <div class="word-item">
    <div class="write-left">
      <p><b>{{wordmes.words}}</b><span>[{{wordmes.spell}}]</span></p>
      <p class="chi-tarn">{{wordmes.meaning}}</p>
    </div>
    <div class="btn-right">
      <!--    :disabled="wordmes.user_phone=='000'" -->
      <van-button plain
                  round
                  type="danger"
                  :disabled="wordmes.user_phone=='000'"
                  @click="delWord(wordmes)">删除</van-button>
      <van-button round
                  color="#e87b61"
                  :disabled="wordmes.user_phone=='000'"
                  @click="updWord(wordmes)">修改</van-button>
    </div>
  </div>
</template>

<script>
import { deleteWord } from '@/api/main'
export default {
  props: {
    wordmes: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {}
  },
  methods: {
    // 删除单词
    async delWord(word) {
      let res = await deleteWord(word.word_id, word.user_phone)
      console.log(res)
      this.$toast(res.message)
      this.$emit('refreshs')
    },
    // 更新单词
    updWord(word) {
      console.log(word)
      this.$router.push({
        path: '/update',
        query: {
          id: word.word_id
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.word-item {
  display: flex;
  justify-content: space-between;
  margin-top: 0.2667rem;
  padding: 0.2667rem 0.2667rem 0.2667rem 0.4rem;
  height: 1.7333rem;
  background-color: #fff;
  box-sizing: border-box;
  /* 左侧文字 */
  .write-left {
    font-size: 0.5333rem;
    .chi-tarn,
    span {
      font-size: 0.3467rem;
      color: #666;
    }
    span {
      padding-left: 0.2667rem;
    }
    .chi-tarn {
      margin-top: 0.0533rem;
      font-weight: 600;
    }
  }
  .btn-right {
    width: 3.4667rem;
    .van-button {
      height: 0.6667rem;
      margin-left: 5px;
    }
  }
}
</style>